from selenium import webdriver
from selenium.webdriver.common.by import By
import os

# 打开游览器和本地页面
driver = webdriver.Chrome()
url = 'file:///' + os.path.abspath('html') + "/radio-checkbox.html"
driver.get(url)

# 单选框选中
driver.find_element(By.ID,'boy').click()
# 查看是否选中，返回bool
print(driver.find_element(By.ID, 'boy').is_selected())

driver.find_element(By.ID,'girl').click()

print(driver.find_element(By.ID, 'girl').is_selected())

# 多选框选中，全选
# 先找到第二个form标签
form = driver.find_elements(By.TAG_NAME,'form')[1]
ipts = form.find_elements(By.TAG_NAME,'input')
for ipt in ipts:
    ipt.click()

# 关闭游览器
driver.quit()